n=int(input())

def calculate(a,b,op):
    if op=="+":
        return a+b
    elif op=="-":
        return a-b
    elif op=="x":
        return a*b
    else:
        return int(a/b)

for i in range(0,n):
    row=input()
    val=[]
    for i in range(0,len(row)):
        if i%2==0:
            val.append(ord(row[i])-48)
        else:
            val.append(row[i])

    row=val

    stack=[]
    ops=[]
    for item in row:
        if item=="+" or item=="-" or item=="x" or item=="/":
            ops.append(item)

            if len(ops)>=2:
                if ops[-1]=="-" or ops[-1]=="+" or ops[-2]=="x" or ops[-2]=="/":
                    num2=stack.pop()
                    num1=stack.pop()
                    op=ops.pop(-2)
                    stack.append(calculate(num1,num2,op))
        else:
            stack.append(item)

    while len(ops)>0:
        num2=stack.pop()
        num1=stack.pop()
        op=ops.pop()
        stack.append(calculate(num1,num2,op))
    if stack[0]==24:
        print("Yes")
    else:
        print("No")

